const branch = await $`git branch --show-current`
const TEPLATES = {
	'react-native': 'https://github.com/qiuquanwu/react-native-demo.git'
}
echo`当前的分支：${branch}`

let appName = await question('请输入app名称')
//去除appName的空格
appName = appName.replace(/\s/g, '')
if (appName === '') {
	console.log(chalk.red('必须传入app名称'))
	process.exit(1)
}
// 判断appName只能是字母
if (!/^[a-zA-Z]+$/.test(appName)) {
	console.log(chalk.red('app名称只能是字母'))
	process.exit(1)
}

cd('apps')

console.log(chalk.blue('拉取模版'))
await $`git clone ${TEPLATES['react-native']}`
//更改文件名
await $`mv react-native-demo ${appName}`

cd(`${appName}`)
// 删掉原来的git remote
await $`git remote remove origin`
console.log(chalk.green('拉取完成'))

cd('..')
// 安装依赖
console.log(chalk.blue('安装依赖'))

cd('..')
const path = await $`pwd`
echo`当前路径：${path}`
await $`yarn install`
console.log(chalk.green('安装完成'))
